package com.baizhi.controller;

import com.baizhi.entity.Banner;
import com.baizhi.entity.Log;
import com.baizhi.service.LogService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("log")
public class LogController {
    @Autowired
    private LogService logService;
    @RequestMapping("selectAll")
    @ResponseBody
    public Map selectAll(Integer page,Integer limit,String logType){
        Map map = new HashMap();
        System.out.println(logType);
        PageInfo<Log> pageInfo = logService.selectAll(page, limit, logType);
        map.put("code",0);
        map.put("msg","");
        map.put("count",pageInfo.getTotal());
        map.put("data",pageInfo.getList());
        return map;
    }
    @RequestMapping("deleteByIds")
    @ResponseBody
    public Map deleteByIds(int[] ids){
        Map map = new HashMap();
        System.out.println(ids);
        try {
            logService.deleteByIds(ids);
            map.put("flag",true);
        } catch (Exception e) {
            map.put("flag",false);
            e.printStackTrace();
        }
        return map;
    }
}
